﻿#include "modbuscontrol.h"

ModBusControl::ModBusControl(QObject *parent)
    : QObject{parent}
{

}

void ModBusControl::floatResolution(QString setValue, uint16_t *high, uint16_t *low)
{
    float floatValue = setValue.toFloat();

    // qDebug()<<"当前需要转换的数据为:  "<<test;

    uint8_t midValue [4] = {0};

    memcpy(midValue,&floatValue,sizeof(float));   // 可用

    uint16_t transResult[2] = {0};

    // qDebug()<<"8-高位: " <<midValue[3];
    // qDebug()<<"8-低位: " <<midValue[2];
    // qDebug()<<"8-次低位: " <<midValue[1];
    // qDebug()<<"8-低位: " <<midValue[0];

    transResult[0] = (midValue[3] << 8| midValue[2]);
    transResult[1] = (midValue[1] << 8| midValue[0]);

    // qDebug()<<"16-高位"<<midValue01[0];
    // qDebug()<<"16-低位"<<midValue01[1];

    *high = transResult[0];
    *low = transResult[1];
}

float ModBusControl::combinationToFloat(quint16 valueH, quint16 valueL)
{
    float result = 0;

    uint32_t midValue = (static_cast<uint32_t>(valueH) << 16) | static_cast<uint32_t>(valueL);

    result = *(float*)&midValue;

    return result;
}

int ModBusControl::combinationToInt(quint16 valueH, quint16 valueL)
{
    int result = 0;

    uint32_t midValue = (static_cast<uint32_t>(valueH) << 16) | static_cast<uint32_t>(valueL);

    result = *(int*)&midValue;

    return result;
}

void ModBusControl::write_modbus_rtu_Coils(QString address, QString newValue)
{
    int Addr = address.toInt() ;

    uint16_t value = newValue.toUShort();

    QModbusDataUnit writeUnit(QModbusDataUnit::Coils,Addr,1);

    writeUnit.setValue(0,value);

    // 发送写请求
    if (QModbusReply* reply = m_Modbus->sendWriteRequest(writeUnit, 1))
    {
        if (!reply->isFinished())
        {
            QObject::connect(reply, &QModbusReply::finished, [reply, Addr, value]()
                             {
                                 if (reply->error() != QModbusDevice::NoError)
                                 {
                                     qDebug() << "写入 线圈 失败:" << reply->error();
                                 } else
                                 {
                                     qDebug() << "写入 线圈 成功" <<"  地址: "<<Addr<<" 写入值: "<<value;
                                 }
                                 reply->deleteLater();
                             });
        } else {
            reply->deleteLater();
        }
    } else {
        qDebug() << "发送 写入线圈 请求失败";
    }
}

void ModBusControl::write_modbus_rtu_Hold_F(QString address, QString newValue)
{
    // qDebug()<<"写入 双字寄存器";

    int writeAdd = address.toInt();

    uint16_t write_regs[2] = {0};

    // 高位在前  低位在后
    floatResolution(newValue,&write_regs[1],&write_regs[0]);

    //写入到 holdaddress 地址    写两个寄存器
    QModbusDataUnit writeUnit(QModbusDataUnit::HoldingRegisters, writeAdd, 2);

    // 写入数据体设置
    for (int i = 0; i < writeUnit.valueCount(); ++i) {
        writeUnit.setValue(i, write_regs[i]);
    }

    // 发送写请求
    if (QModbusReply* reply = m_Modbus->sendWriteRequest(writeUnit, 1))
    { // 1为从站地址
        if (!reply->isFinished())
        {
            QObject::connect(reply, &QModbusReply::finished, [reply, address, newValue]()
                             {
                                 if (reply->error() != QModbusDevice::NoError)
                                 {
                                     qDebug() << "写入 保持寄存器 失败:" <<"  地址 : "<<address<<"  写入值: "<<newValue<<"  "<< reply->error();
                                 } else
                                 {
                                     qDebug() << "写入 保持寄存器 成功"<<"  地址 : "<<address<<"  写入值: "<<newValue;
                                 }
                                 reply->deleteLater();
                             });
        } else {
            reply->deleteLater();
        }
    } else {
        qDebug() << "发送 写入保持寄存器 请求失败" <<"  地址 : "<<address<<"  写入值: "<<newValue;
    }
}

void ModBusControl::write_modbus_rtu_Hold(QString address, QString newValue)
{
    // qDebug()<<"写入 保持寄存器 16位";

    int writeAdd = address.toInt();

    quint16 value = newValue.toInt();

    // qDebug()<<"高位数据: "<<write_regs[1];
    // qDebug()<<"低位数据: "<<write_regs[0];

    //写入到 holdaddress 地址    写两个寄存器
    QModbusDataUnit writeUnit(QModbusDataUnit::HoldingRegisters, writeAdd, 1);

    writeUnit.setValue(0,value);

    // 发送写请求
    if (QModbusReply* reply = m_Modbus->sendWriteRequest(writeUnit, 1))
    { // 1为从站地址
        if (!reply->isFinished())
        {
            QObject::connect(reply, &QModbusReply::finished, [reply, address, newValue]()
                             {
                                 if (reply->error() != QModbusDevice::NoError)
                                 {
                                     qDebug() << "写入 保持寄存器 失败:" <<"  地址 : "<<address<<"  写入值: "<<newValue<<"  "<< reply->error();
                                 } else
                                 {
                                     qDebug() << "写入 保持寄存器 成功"<<"  地址 : "<<address<<"  写入值: "<<newValue;
                                 }
                                 reply->deleteLater();
                             });
        } else {
            reply->deleteLater();
        }
    } else {
        qDebug() << "发送 写入保持寄存器 请求失败" <<"  地址 : "<<address<<"  写入值: "<<newValue;
    }
}

void ModBusControl::read_modbus_rtu_Coils()
{
    int readAddr = 0;

    QModbusDataUnit readUnit(QModbusDataUnit::Coils,readAddr,535);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            scramWarnSig = resultUnit.value(2);
                            servoWarnSig = resultUnit.value(3);
                            MechineRunningState = resultUnit.value(7);
                            // qDebug()<<"M7: "<<MechineRunningState;
                            FindZeroState = resultUnit.value(9);
                            // qDebug()<<"M9: "<<FindZeroState;
                            ZeroGoingState = resultUnit.value(6);
                            // qDebug()<<"M6: "<<ZeroGoingState;
                            F_LimitWarnSig = resultUnit.value(31);
                            R_LimitWarnSig = resultUnit.value(36);
                            ForbidLeftRun = resultUnit.value(42);
                            ForbidRightRun = resultUnit.value(43);
                            CurrentLocationEqualLocation = resultUnit.value(47);
                            ZeroLocationFaled = resultUnit.value(52);
                            ServoReady = resultUnit.value(56);
                            ReadLocationFailed = resultUnit.value(57);
                            ReadLocationOver = resultUnit.value(58);
                            ForbidRun_NotFindZero = resultUnit.value(59);
                            NotChooseMechine = resultUnit.value(64);
                            WorkingForbidImpact = resultUnit.value(68);
                            SawErrForbidImpact = resultUnit.value(69);

                            CurrentSectionesWorked = resultUnit.value(73);

                            SawNotRunForbidOut = resultUnit.value(76);
                            NotImpactForbidOut = resultUnit.value(77);
                            CurrentLocationForbidOut = resultUnit.value(80);

                            Long_WorkState = resultUnit.value(96);
                            Short_WorkState = resultUnit.value(97);
                            JM_WorkState = resultUnit.value(98);

                            ExtraLong_Locating = resultUnit.value(103);
                            lg_observe_state = resultUnit.value(109);
                            JM_LC_Err = resultUnit.value(114);
                            SetExtraShortLessCDLC = resultUnit.value(134);
                            AutoPrintRun = resultUnit.value(135);
                            // qDebug()<<AutoPrintRun;
                            SawInPlaceSignalErr = resultUnit.value(137);
                            ExtraShortOrigin = resultUnit.value(143);
                            ExtraLongLocation = resultUnit.value(149);
                            LocationZeroOver = resultUnit.value(152);
                            Forbid_45NB = resultUnit.value(153);
                            ForbidRightMechineMove = resultUnit.value(159);
                            ChangeSawMethod = resultUnit.value(164);
                            ErrCorrected = resultUnit.value(170);
                            CleanBatteryWarning = resultUnit.value(196);
                            CleanBatteryDone = resultUnit.value(197);

                            impactState = resultUnit.value(239);
                            sawState = resultUnit.value(240);
                            gjState = resultUnit.value(241);
                            Q_TLJ_Over = resultUnit.value(243);
                            Z_TLJ_Over = resultUnit.value(244);
                            H_TLJ_Over = resultUnit.value(245);

                            Q_TL_Err = resultUnit.value(250);
                            Z_TL_Err = resultUnit.value(251);
                            H_TL_Err = resultUnit.value(252);

                            Q_TLJ_LS_State = resultUnit.value(384);
                            Z_TLJ_LS_State = resultUnit.value(385);
                            H_TLJ_LS_State = resultUnit.value(386);
                            Q_TLJ_Enable = resultUnit.value(387);
                            Z_TLJ_Enable = resultUnit.value(388);
                            H_TLJ_Enable = resultUnit.value(389);

                            leftSawAngleBack = resultUnit.value(390);
                            rightSawAngleBack = resultUnit.value(391);

                            Servo_Mode = resultUnit.value(392);
                            SawChoose_Mode = resultUnit.value(393);
                            NBWB_Mode = resultUnit.value(394);
                            AutoObserve_Exist = resultUnit.value(396);
                            TLJ_Exist = resultUnit.value(397);
                            Printer_Exist = resultUnit.value(398);
                            DoubleSaw_Open = resultUnit.value(399);
                            Encoder_Mode = resultUnit.value(400);
                            CompensateBtn01_Any = resultUnit.value(401);
                            CompensateBtn02_Any = resultUnit.value(402);
                            CompensateBtn03_Any = resultUnit.value(403);
                            CompensateBtn04_Any = resultUnit.value(404);
                            CompensateBtn05_Any = resultUnit.value(405);
                            CompensateBtn06_Any = resultUnit.value(406);
                            CompensateBtn07_Any = resultUnit.value(407);
                            CompensateBtn08_Any = resultUnit.value(408);
                            CompensateBtn09_Any = resultUnit.value(409);
                            CompensateBtn10_Any = resultUnit.value(410);
                            CompensateBtn11_Any = resultUnit.value(411);
                            CompensateBtn12_Any = resultUnit.value(412);
                            CompensateBtn13_Any = resultUnit.value(413);
                            CompensateBtn14_Any = resultUnit.value(414);
                            CompensateBtn15_Any = resultUnit.value(415);
                            CompensateBtn16_Any = resultUnit.value(416);
                            CompensateBtn17_Any = resultUnit.value(417);
                            CompensateBtn18_Any = resultUnit.value(418);
                            CompensateBtn19_Any = resultUnit.value(419);
                            CompensateBtn20_Any = resultUnit.value(420);
                            BJZB_Btn = resultUnit.value(421);
                            TLJ_State = resultUnit.value(499);
                            Scram_Mode = resultUnit.value(500);                        
                            Servo_Warning_Mode = resultUnit.value(501);
                            LimitBtn_Mode = resultUnit.value(502);
                            JT_Knob_Mode = resultUnit.value(503);
                            DCF_Power_Mode = resultUnit.value(509);
                            Knob_Program = resultUnit.value(510);
                            AutoPrint = resultUnit.value(511);
                            GJTIME_Mode = resultUnit.value(528);
                            LS_Exist = resultUnit.value(529);
                            Angle45_Mode = resultUnit.value(530);

                        }
                        else
                        {
                            qDebug()<<"读取 弹窗报警信息 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_modbus_rtu_HoldingRegisters()
{

    QModbusDataUnit readUnit(QModbusDataUnit::HoldingRegisters,64,100);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();
                    workValue = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));                                        
                    workCurrentOrder = QString("%1").arg(resultUnit.value(13));
                    // qDebug()<<"当前序号: "<<workCurrentOrder;

                }
            });
        }
    }


    int readAddr1 = 200;

    QModbusDataUnit readUnit1(QModbusDataUnit::HoldingRegisters,readAddr1,100);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit1,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();
                    Per_Pulse_Count = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                    Per_Move_Distance = (QString("%1").arg(combinationToFloat(resultUnit.value(3),resultUnit.value(2)),0,'f',2));;
                    XAxisCurrentLocation = (QString("%1").arg(combinationToFloat(resultUnit.value(5),resultUnit.value(4)),0,'f',2));;
                    LocationSpeed = (QString("%1").arg(combinationToFloat(resultUnit.value(7),resultUnit.value(6)),0,'f',2));;
                    F_L_Speed_Time = QString("%1").arg(resultUnit.value(8));
                    OriginValue = (QString("%1").arg(combinationToFloat(resultUnit.value(11),resultUnit.value(10)),0,'f',2));
                    LC_value = (QString("%1").arg(combinationToFloat(resultUnit.value(13),resultUnit.value(12)),0,'f',2));
                    LG_value = (QString("%1").arg(combinationToFloat(resultUnit.value(15),resultUnit.value(14)),0,'f',2));
                    Max_Cut_Longth = (QString("%1").arg(combinationToFloat(resultUnit.value(17),resultUnit.value(16)),0,'f',2));
                    R_Limit = (QString("%1").arg(combinationToFloat(resultUnit.value(19),resultUnit.value(18)),0,'f',2));
                    F_Zero_HSpeed = (QString("%1").arg(combinationToFloat(resultUnit.value(21),resultUnit.value(20)),0,'f',2));
                    F_Zero_LSpeed = (QString("%1").arg(combinationToFloat(resultUnit.value(23),resultUnit.value(22)),0,'f',2));
                    ExtraShort_LC = (QString("%1").arg(combinationToFloat(resultUnit.value(25),resultUnit.value(24)),0,'f',2));
                    ExtraLong_LC = (QString("%1").arg(combinationToFloat(resultUnit.value(27),resultUnit.value(26)),0,'f',2));
                    JMSectiones_JM = QString("%1").arg(resultUnit.value(28));
                    knobMode = QString("%1").arg(resultUnit.value(29));
                    sectionSetting = QString("%1").arg(resultUnit.value(30));
                    CurrentSectiones = QString("%1").arg(resultUnit.value(31));
                    LeftSaw_GJTime = (QString("%1").arg(combinationToFloat(resultUnit.value(33),resultUnit.value(32)),0,'f',2));
                    RightSaw_GJTime = (QString("%1").arg(combinationToFloat(resultUnit.value(35),resultUnit.value(34)),0,'f',2));
                    DCF_OutageDelay = (QString("%1").arg(combinationToFloat(resultUnit.value(39),resultUnit.value(38)),0,'f',2));
                    LS_Locatoin = (QString("%1").arg(combinationToFloat(resultUnit.value(83),resultUnit.value(82)),0,'f',2));
                    LS_Width = (QString("%1").arg(combinationToFloat(resultUnit.value(85),resultUnit.value(84)),0,'f',2));
                    Z_TLJ_Down_Limit = (QString("%1").arg(combinationToFloat(resultUnit.value(87),resultUnit.value(86)),0,'f',2));
                }
                else
                {
                    qDebug()<<"读取 保持寄存器 200 - 300 失败"<<reply->errorString();
                }

                reply->deleteLater();
            });
        }
    }


    int readAddr2 = 374;

    QModbusDataUnit readUnit2(QModbusDataUnit::HoldingRegisters,readAddr2,26);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit2,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();
                    LR_Blow_Time = QString("%1").arg(resultUnit.value(0));
                    LS_LocationCompensate = (QString("%1").arg(combinationToFloat(resultUnit.value(5),resultUnit.value(4)),0,'f',2));
                    SingleSaw45_Compensate = (QString("%1").arg(combinationToFloat(resultUnit.value(23),resultUnit.value(22)),0,'f',2));
                }
                else
                {
                    qDebug()<<"读取 保持寄存器 374 - 400 失败"<<reply->errorString();
                }

                reply->deleteLater();
            });
        }
    }

    int readAddr3 = 602;

    QModbusDataUnit readUnit3(QModbusDataUnit::HoldingRegisters,readAddr3,12);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit3,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();

                    Brake_Close_Delay = QString("%1").arg(resultUnit.value(0));
                    float mid = Brake_Close_Delay.toFloat();
                    Brake_Close_Delay = QString::number(mid/10,'f',2);

                    QT_Safe_Location = (QString("%1").arg(combinationToFloat(resultUnit.value(3),resultUnit.value(2)),0,'f',2));
                    ZT_L_Safe_Location = (QString("%1").arg(combinationToFloat(resultUnit.value(5),resultUnit.value(4)),0,'f',2));
                    HT_Safe_Location = (QString("%1").arg(combinationToFloat(resultUnit.value(7),resultUnit.value(6)),0,'f',2));
                    ZT_U_Safe_Location = (QString("%1").arg(combinationToFloat(resultUnit.value(9),resultUnit.value(8)),0,'f',2));
                    TLJ_Safe_Distance = (QString("%1").arg(combinationToFloat(resultUnit.value(11),resultUnit.value(10)),0,'f',2));

                }
                else
                {
                    qDebug()<<"读取 保持寄存器 602 - 616 失败"<<reply->errorString();
                }

                reply->deleteLater();
            });
        }
    }

    int readAddr4 = 1270;

    QModbusDataUnit readUnit4(QModbusDataUnit::HoldingRegisters,readAddr4,100);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit4,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();

                    currentSectiones_JM = QString("%1").arg(QString::number(resultUnit.value(0),'f',0));
                    workedSectiones_JM = QString("%1").arg(QString::number(resultUnit.value(1),'f',0));
                    JMLongth_JM = (QString("%1").arg(combinationToFloat(resultUnit.value(3),resultUnit.value(2)),0,'f',2));
                    DB_JM = (QString("%1").arg(combinationToFloat(resultUnit.value(5),resultUnit.value(4)),0,'f',2));
                    MaterialLongth_JM = (QString("%1").arg(combinationToFloat(resultUnit.value(7),resultUnit.value(6)),0,'f',2));
                    Brake_Open_Time = (QString("%1").arg(combinationToFloat(resultUnit.value(9),resultUnit.value(8)),0,'f',2));
                    ImpactTime = (QString("%1").arg(combinationToFloat(resultUnit.value(11),resultUnit.value(10)),0,'f',2));
                    LG_Detection_Time = (QString("%1").arg(combinationToFloat(resultUnit.value(19),resultUnit.value(18)),0,'f',2));
                    LG_CC_DL = (QString("%1").arg(combinationToFloat(resultUnit.value(21),resultUnit.value(20)),0,'f',2));
                    MiniLongth_JM = (QString("%1").arg(combinationToFloat(resultUnit.value(23),resultUnit.value(22)),0,'f',2));
                    Q_TLJ_Location = (QString("%1").arg(combinationToFloat(resultUnit.value(25),resultUnit.value(24)),0,'f',2));
                    Z_TLJ_Up_Limit = (QString("%1").arg(combinationToFloat(resultUnit.value(27),resultUnit.value(26)),0,'f',2));
                    H_TLJ_Location = (QString("%1").arg(combinationToFloat(resultUnit.value(29),resultUnit.value(28)),0,'f',2));

                    Location_Compensate01 = (QString("%1").arg(combinationToFloat(resultUnit.value(33),resultUnit.value(32)),0,'f',2));
                    Location_Compensate02 = (QString("%1").arg(combinationToFloat(resultUnit.value(35),resultUnit.value(34)),0,'f',2));
                    Location_Compensate03 = (QString("%1").arg(combinationToFloat(resultUnit.value(37),resultUnit.value(36)),0,'f',2));
                    Location_Compensate04 = (QString("%1").arg(combinationToFloat(resultUnit.value(39),resultUnit.value(38)),0,'f',2));
                    Location_Compensate05 = (QString("%1").arg(combinationToFloat(resultUnit.value(41),resultUnit.value(40)),0,'f',2));
                    Location_Compensate06 = (QString("%1").arg(combinationToFloat(resultUnit.value(43),resultUnit.value(42)),0,'f',2));
                    Location_Compensate07 = (QString("%1").arg(combinationToFloat(resultUnit.value(45),resultUnit.value(44)),0,'f',2));
                    Location_Compensate08 = (QString("%1").arg(combinationToFloat(resultUnit.value(47),resultUnit.value(46)),0,'f',2));
                    Location_Compensate09 = (QString("%1").arg(combinationToFloat(resultUnit.value(49),resultUnit.value(48)),0,'f',2));
                    Location_Compensate10 = (QString("%1").arg(combinationToFloat(resultUnit.value(51),resultUnit.value(50)),0,'f',2));
                    Location_Compensate11 = (QString("%1").arg(combinationToFloat(resultUnit.value(53),resultUnit.value(52)),0,'f',2));
                    Location_Compensate12 = (QString("%1").arg(combinationToFloat(resultUnit.value(55),resultUnit.value(54)),0,'f',2));
                    Location_Compensate13 = (QString("%1").arg(combinationToFloat(resultUnit.value(57),resultUnit.value(56)),0,'f',2));
                    Location_Compensate14 = (QString("%1").arg(combinationToFloat(resultUnit.value(59),resultUnit.value(58)),0,'f',2));
                    Location_Compensate15 = (QString("%1").arg(combinationToFloat(resultUnit.value(61),resultUnit.value(60)),0,'f',2));
                    Location_Compensate16 = (QString("%1").arg(combinationToFloat(resultUnit.value(63),resultUnit.value(62)),0,'f',2));
                    Location_Compensate17 = (QString("%1").arg(combinationToFloat(resultUnit.value(65),resultUnit.value(64)),0,'f',2));
                    Location_Compensate18 = (QString("%1").arg(combinationToFloat(resultUnit.value(67),resultUnit.value(66)),0,'f',2));
                    Location_Compensate19 = (QString("%1").arg(combinationToFloat(resultUnit.value(69),resultUnit.value(68)),0,'f',2));
                    Location_Compensate20 = (QString("%1").arg(combinationToFloat(resultUnit.value(71),resultUnit.value(70)),0,'f',2));
                    //  未使用变量
                    Location_Compensate21 = (QString("%1").arg(combinationToFloat(resultUnit.value(73),resultUnit.value(72)),0,'f',2));
                    Location_Compensate22 = (QString("%1").arg(combinationToFloat(resultUnit.value(75),resultUnit.value(74)),0,'f',2));
                    Location_Compensate23 = (QString("%1").arg(combinationToFloat(resultUnit.value(77),resultUnit.value(76)),0,'f',2));
                    Location_Compensate24 = (QString("%1").arg(combinationToFloat(resultUnit.value(79),resultUnit.value(78)),0,'f',2));
                }
                else
                {
                    qDebug()<<"读取 保持寄存器 1270 - 1370 失败"<<reply->errorString();
                }

                reply->deleteLater();
            });
        }
    }


    int readAddr5 = 1600;

    QModbusDataUnit readUnit5(QModbusDataUnit::HoldingRegisters,readAddr5,100);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit5,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            m_Length01_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                            m_Length02_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(3),resultUnit.value(2)),0,'f',2));
                            m_Length03_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(5),resultUnit.value(4)),0,'f',2));
                            m_Length04_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(7),resultUnit.value(6)),0,'f',2));
                            m_Length05_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(9),resultUnit.value(8)),0,'f',2));
                            m_Length06_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(11),resultUnit.value(10)),0,'f',2));
                            m_Length07_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(13),resultUnit.value(12)),0,'f',2));
                            m_Length08_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(15),resultUnit.value(14)),0,'f',2));
                            m_Length09_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(17),resultUnit.value(16)),0,'f',2));
                            m_Length10_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(19),resultUnit.value(18)),0,'f',2));
                            m_Length11_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(21),resultUnit.value(20)),0,'f',2));
                            m_Length12_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(23),resultUnit.value(22)),0,'f',2));
                            m_Length13_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(25),resultUnit.value(24)),0,'f',2));
                            m_Length14_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(27),resultUnit.value(26)),0,'f',2));
                            m_Length15_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(29),resultUnit.value(28)),0,'f',2));
                            m_Length16_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(31),resultUnit.value(30)),0,'f',2));
                            m_Length17_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(33),resultUnit.value(32)),0,'f',2));
                            m_Length18_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(35),resultUnit.value(34)),0,'f',2));
                            m_Length19_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(37),resultUnit.value(36)),0,'f',2));
                            m_Length20_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(39),resultUnit.value(38)),0,'f',2));

                            LeftAngle01_QR = QString("%1").arg(resultUnit.value(40));
                            RightAngle01_QR = QString("%1").arg(resultUnit.value(41));

                            LeftAngle02_QR = QString("%1").arg(resultUnit.value(42));
                            RightAngle02_QR = QString("%1").arg(resultUnit.value(43));

                            LeftAngle03_QR = QString("%1").arg(resultUnit.value(44));
                            RightAngle03_QR = QString("%1").arg(resultUnit.value(45));

                            LeftAngle04_QR = QString("%1").arg(resultUnit.value(46));
                            RightAngle04_QR = QString("%1").arg(resultUnit.value(47));

                            LeftAngle05_QR = QString("%1").arg(resultUnit.value(48));
                            RightAngle05_QR = QString("%1").arg(resultUnit.value(49));

                            LeftAngle06_QR = QString("%1").arg(resultUnit.value(50));
                            RightAngle06_QR = QString("%1").arg(resultUnit.value(51));

                            LeftAngle07_QR = QString("%1").arg(resultUnit.value(52));
                            RightAngle07_QR = QString("%1").arg(resultUnit.value(53));

                            LeftAngle08_QR = QString("%1").arg(resultUnit.value(54));
                            RightAngle08_QR = QString("%1").arg(resultUnit.value(55));

                            LeftAngle09_QR = QString("%1").arg(resultUnit.value(56));
                            RightAngle09_QR = QString("%1").arg(resultUnit.value(57));

                            LeftAngle10_QR = QString("%1").arg(resultUnit.value(58));
                            RightAngle10_QR = QString("%1").arg(resultUnit.value(59));

                            LeftAngle11_QR = QString("%1").arg(resultUnit.value(60));
                            RightAngle11_QR = QString("%1").arg(resultUnit.value(61));

                            LeftAngle12_QR = QString("%1").arg(resultUnit.value(62));
                            RightAngle12_QR = QString("%1").arg(resultUnit.value(63));

                            LeftAngle13_QR = QString("%1").arg(resultUnit.value(64));
                            RightAngle13_QR = QString("%1").arg(resultUnit.value(65));

                            LeftAngle14_QR = QString("%1").arg(resultUnit.value(66));
                            RightAngle14_QR = QString("%1").arg(resultUnit.value(67));

                            LeftAngle15_QR = QString("%1").arg(resultUnit.value(68));
                            RightAngle15_QR = QString("%1").arg(resultUnit.value(69));

                            LeftAngle16_QR = QString("%1").arg(resultUnit.value(70));
                            RightAngle16_QR = QString("%1").arg(resultUnit.value(71));

                            LeftAngle17_QR = QString("%1").arg(resultUnit.value(72));
                            RightAngle17_QR = QString("%1").arg(resultUnit.value(73));

                            LeftAngle18_QR = QString("%1").arg(resultUnit.value(74));
                            RightAngle18_QR = QString("%1").arg(resultUnit.value(75));

                            LeftAngle19_QR = QString("%1").arg(resultUnit.value(76));
                            RightAngle19_QR = QString("%1").arg(resultUnit.value(77));

                            LeftAngle20_QR = QString("%1").arg(resultUnit.value(78));
                            RightAngle20_QR = QString("%1").arg(resultUnit.value(79));

                            Count01_QR = QString("%1").arg(resultUnit.value(80));
                            Count02_QR = QString("%1").arg(resultUnit.value(81));
                            Count03_QR = QString("%1").arg(resultUnit.value(82));
                            Count04_QR = QString("%1").arg(resultUnit.value(83));
                            Count05_QR = QString("%1").arg(resultUnit.value(84));
                            Count06_QR = QString("%1").arg(resultUnit.value(85));
                            Count07_QR = QString("%1").arg(resultUnit.value(86));
                            Count08_QR = QString("%1").arg(resultUnit.value(87));
                            Count09_QR = QString("%1").arg(resultUnit.value(88));
                            Count10_QR = QString("%1").arg(resultUnit.value(89));
                            Count11_QR = QString("%1").arg(resultUnit.value(90));
                            Count12_QR = QString("%1").arg(resultUnit.value(91));
                            Count13_QR = QString("%1").arg(resultUnit.value(92));
                            Count14_QR = QString("%1").arg(resultUnit.value(93));
                            Count15_QR = QString("%1").arg(resultUnit.value(94));
                            Count16_QR = QString("%1").arg(resultUnit.value(95));
                            Count17_QR = QString("%1").arg(resultUnit.value(96));
                            Count18_QR = QString("%1").arg(resultUnit.value(97));
                            Count19_QR = QString("%1").arg(resultUnit.value(98));
                            Count20_QR = QString("%1").arg(resultUnit.value(99));

                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }

    int readAddr6 = 1700;

    QModbusDataUnit readUnit6(QModbusDataUnit::HoldingRegisters,readAddr6,20);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit6,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Worked_Count01_QR = QString("%1").arg(resultUnit.value(0));
                            Worked_Count02_QR = QString("%1").arg(resultUnit.value(1));
                            Worked_Count03_QR = QString("%1").arg(resultUnit.value(2));
                            Worked_Count04_QR = QString("%1").arg(resultUnit.value(3));
                            Worked_Count05_QR = QString("%1").arg(resultUnit.value(4));
                            Worked_Count06_QR = QString("%1").arg(resultUnit.value(5));
                            Worked_Count07_QR = QString("%1").arg(resultUnit.value(6));
                            Worked_Count08_QR = QString("%1").arg(resultUnit.value(7));
                            Worked_Count09_QR = QString("%1").arg(resultUnit.value(8));
                            Worked_Count10_QR = QString("%1").arg(resultUnit.value(9));
                            Worked_Count11_QR = QString("%1").arg(resultUnit.value(10));
                            Worked_Count12_QR = QString("%1").arg(resultUnit.value(11));
                            Worked_Count13_QR = QString("%1").arg(resultUnit.value(12));
                            Worked_Count14_QR = QString("%1").arg(resultUnit.value(13));
                            Worked_Count15_QR = QString("%1").arg(resultUnit.value(14));
                            Worked_Count16_QR = QString("%1").arg(resultUnit.value(15));
                            Worked_Count17_QR = QString("%1").arg(resultUnit.value(16));
                            Worked_Count18_QR = QString("%1").arg(resultUnit.value(17));
                            Worked_Count19_QR = QString("%1").arg(resultUnit.value(18));
                            Worked_Count20_QR = QString("%1").arg(resultUnit.value(19));

                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }

    // Doing

    int readAddr7 = 1750;

    QModbusDataUnit readUnit7(QModbusDataUnit::HoldingRegisters,readAddr7,120);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit7,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();

                    Location_DownLimit01_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                    Location_UpLimit01_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(3),resultUnit.value(2)),0,'f',2));
                    Location_Compensate01_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(5),resultUnit.value(4)),0,'f',2));

                    Location_DownLimit02_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(7),resultUnit.value(6)),0,'f',2));
                    Location_UpLimit02_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(9),resultUnit.value(8)),0,'f',2));
                    Location_Compensate02_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(11),resultUnit.value(10)),0,'f',2));

                    Location_DownLimit03_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(13),resultUnit.value(12)),0,'f',2));
                    Location_UpLimit03_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(15),resultUnit.value(14)),0,'f',2));
                    Location_Compensate03_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(17),resultUnit.value(16)),0,'f',2));

                    Location_DownLimit04_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(19),resultUnit.value(18)),0,'f',2));
                    Location_UpLimit04_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(21),resultUnit.value(20)),0,'f',2));
                    Location_Compensate04_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(23),resultUnit.value(22)),0,'f',2));

                    Location_DownLimit05_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(25),resultUnit.value(24)),0,'f',2));
                    Location_UpLimit05_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(27),resultUnit.value(26)),0,'f',2));
                    Location_Compensate05_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(29),resultUnit.value(28)),0,'f',2));

                    Location_DownLimit06_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(31),resultUnit.value(30)),0,'f',2));
                    Location_UpLimit06_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(33),resultUnit.value(32)),0,'f',2));
                    Location_Compensate06_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(35),resultUnit.value(34)),0,'f',2));

                    Location_DownLimit07_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(37),resultUnit.value(36)),0,'f',2));
                    Location_UpLimit07_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(39),resultUnit.value(38)),0,'f',2));
                    Location_Compensate07_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(41),resultUnit.value(40)),0,'f',2));

                    Location_DownLimit08_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(43),resultUnit.value(42)),0,'f',2));
                    Location_UpLimit08_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(45),resultUnit.value(44)),0,'f',2));
                    Location_Compensate08_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(47),resultUnit.value(46)),0,'f',2));

                    Location_DownLimit09_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(49),resultUnit.value(48)),0,'f',2));
                    Location_UpLimit09_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(51),resultUnit.value(50)),0,'f',2));
                    Location_Compensate09_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(53),resultUnit.value(52)),0,'f',2));

                    Location_DownLimit10_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(55),resultUnit.value(54)),0,'f',2));
                    Location_UpLimit10_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(57),resultUnit.value(56)),0,'f',2));
                    Location_Compensate10_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(59),resultUnit.value(58)),0,'f',2));

                    Location_DownLimit11_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(61),resultUnit.value(60)),0,'f',2));
                    Location_UpLimit11_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(63),resultUnit.value(62)),0,'f',2));
                    Location_Compensate11_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(65),resultUnit.value(64)),0,'f',2));

                    Location_DownLimit12_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(67),resultUnit.value(66)),0,'f',2));
                    Location_UpLimit12_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(69),resultUnit.value(68)),0,'f',2));
                    Location_Compensate12_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(71),resultUnit.value(70)),0,'f',2));

                    Location_DownLimit13_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(73),resultUnit.value(72)),0,'f',2));
                    Location_UpLimit13_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(75),resultUnit.value(74)),0,'f',2));
                    Location_Compensate13_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(77),resultUnit.value(76)),0,'f',2));

                    Location_DownLimit14_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(79),resultUnit.value(78)),0,'f',2));
                    Location_UpLimit14_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(81),resultUnit.value(80)),0,'f',2));
                    Location_Compensate14_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(83),resultUnit.value(82)),0,'f',2));

                    Location_DownLimit15_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(85),resultUnit.value(84)),0,'f',2));
                    Location_UpLimit15_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(87),resultUnit.value(86)),0,'f',2));
                    Location_Compensate15_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(89),resultUnit.value(88)),0,'f',2));

                    Location_DownLimit16_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(91),resultUnit.value(90)),0,'f',2));
                    Location_UpLimit16_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(93),resultUnit.value(92)),0,'f',2));
                    Location_Compensate16_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(95),resultUnit.value(94)),0,'f',2));

                    Location_DownLimit17_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(97),resultUnit.value(96)),0,'f',2));
                    Location_UpLimit17_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(99),resultUnit.value(98)),0,'f',2));
                    Location_Compensate17_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(101),resultUnit.value(100)),0,'f',2));

                    Location_DownLimit18_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(103),resultUnit.value(102)),0,'f',2));
                    Location_UpLimit18_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(105),resultUnit.value(104)),0,'f',2));
                    Location_Compensate18_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(107),resultUnit.value(106)),0,'f',2));

                    Location_DownLimit19_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(109),resultUnit.value(108)),0,'f',2));
                    Location_UpLimit19_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(111),resultUnit.value(110)),0,'f',2));
                    Location_Compensate19_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(113),resultUnit.value(112)),0,'f',2));

                    Location_DownLimit20_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(115),resultUnit.value(114)),0,'f',2));
                    Location_UpLimit20_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(117),resultUnit.value(116)),0,'f',2));
                    Location_Compensate20_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(119),resultUnit.value(118)),0,'f',2));

                }
                else
                {
                    qDebug()<<"读取 保持寄存器 1370 - 1470 失败"<<reply->errorString();
                }

                reply->deleteLater();
            });
        }
    }


}

void ModBusControl::read_modbus_rtu_DiscreteInputs()
{

    // /////////////////////   X 区    ///////////////////////////

    // qDebug()<<"读取 - 开关量";
    int readAddr1 = 13312;

    QModbusDataUnit readUnit1(QModbusDataUnit::DiscreteInputs,readAddr1,30);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit1,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();

                    X0 = resultUnit.value(0);
                    X1 = resultUnit.value(1);
                    X2 = resultUnit.value(2);
                    X3 = resultUnit.value(3);
                    X5 = resultUnit.value(5);
                    X6 = resultUnit.value(6);
                    X7 = resultUnit.value(7);
                    X10 = resultUnit.value(8);
                    X11 = resultUnit.value(9);
                    leftSawQW = resultUnit.value(10);  // X12
                    rightSawQW = resultUnit.value(11); // X13
                    leftSawHW = resultUnit.value(12);  // X14
                    rightSawHW = resultUnit.value(13); // X15
                    X16 = resultUnit.value(14);
                    X17 = resultUnit.value(15);
                    X20 = resultUnit.value(16);
                    X21 = resultUnit.value(17);
                    X22 = resultUnit.value(18);
                    X23 = resultUnit.value(19);
                    X24 = resultUnit.value(20);
                    X25 = resultUnit.value(21);
                }
                else
                {
                    qDebug()<<"读取 开关量 X0 - X25失败"<<reply->errorString();
                }

                reply->deleteLater();
            });
        }
    }

    /////////////////////   Y 区    ///////////////////////////

    // qDebug()<<"读取 - 开关量";
    int readAdd2 = 13056;

    QModbusDataUnit readUni2(QModbusDataUnit::DiscreteInputs,readAdd2,30);

    if(auto* reply = (m_Modbus->sendReadRequest(readUni2,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();

                    Y0 = resultUnit.value(0);
                    Y1 = resultUnit.value(1);
                    Y2 = resultUnit.value(2);
                    Y3 = resultUnit.value(3);
                    Y4 = resultUnit.value(4);
                    Y5 = resultUnit.value(5);
                    Y6 = resultUnit.value(6);
                    Y7 = resultUnit.value(7);
                    Y10 = resultUnit.value(8);
                    Y11 = resultUnit.value(9);
                    Y12 = resultUnit.value(10);
                    Y13 = resultUnit.value(11);
                    Y14 = resultUnit.value(12);
                    Y15 = resultUnit.value(13);
                    Y16 = resultUnit.value(14);
                    Y17 = resultUnit.value(15);
                    Y20 = resultUnit.value(16);
                    Y21 = resultUnit.value(17);
                    Y22 = resultUnit.value(18);
                    Y23 = resultUnit.value(19);
                    Y24 = resultUnit.value(20);
                    Y25 = resultUnit.value(21);

                }
                else
                {
                    qDebug()<<"读取 开关量 Y0 - Y27 失败"<<reply->errorString();
                }

                reply->deleteLater();
            });
        }
    }
}

void ModBusControl::read_M_172_Coils()
{
    // qDebug()<<"读取 - 开关量";
    int readAdd = 172;

    QModbusDataUnit readUni(QModbusDataUnit::Coils,readAdd,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUni,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();

                    m_172 = resultUnit.value(0);
                    // qDebug()<<"M_172: "<<m_172;

                }
                else
                {
                    qDebug()<<"读取 开关量 M_172 失败"<<reply->errorString();
                }

                reply->deleteLater();
            });
        }
    }
}

void ModBusControl::read_M_46_Coils()
{
    int readAdd = 46;

    QModbusDataUnit readUni(QModbusDataUnit::Coils,readAdd,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUni,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();

                    m_46 = resultUnit.value(0);
                    // qDebug()<<"M_46: "<<m_46;

                }
                else
                {
                    qDebug()<<"读取 开关量 M_46 失败"<<reply->errorString();
                }

                reply->deleteLater();
            });
        }
    }
}

void ModBusControl::read_D_156_Holdregisters()
{
    int readAddr7 = 156;

    QModbusDataUnit readUnit7(QModbusDataUnit::HoldingRegisters,readAddr7,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit7,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
            {
                if(reply->error() == QModbusDevice::NoError)
                {
                    const QModbusDataUnit resultUnit = reply->result();

                    d_156 = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                    // qDebug()<<"D_156: "<<d_156;

                }
                else
                {
                    qDebug()<<"读取 保持寄存器 156 失败"<<reply->errorString();
                }

                reply->deleteLater();
            });
        }
    }
}

void ModBusControl::read_PopUp_Warning_Message_state()
{
    // 读取 位置清零失败 报警提示;
    int readAddr1 = 52;

    QModbusDataUnit readUnit1(QModbusDataUnit::Coils,readAddr1,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit1,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ZeroLocationFaled = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 位置清零失败提示 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }

    // 读取 伺服未准备好 报警提示;
    int readAddr2 = 56;

    QModbusDataUnit readUnit2(QModbusDataUnit::Coils,readAddr2,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit2,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ServoReady = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 伺服未准备好提示 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 读取位置失败 报警提示;
    int readAddr3 = 57;

    QModbusDataUnit readUnit3(QModbusDataUnit::Coils,readAddr3,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit3,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ReadLocationFailed = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 读取位置失败 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 读取位置完成 报警提示;
    int readAddr4 = 58;

    QModbusDataUnit readUnit4(QModbusDataUnit::Coils,readAddr4,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit4,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ReadLocationOver = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 读取位置完成 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 未找零禁止运行 报警提示;
    int readAddr5 = 59;

    QModbusDataUnit readUnit5(QModbusDataUnit::Coils,readAddr5,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit5,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ForbidRun_NotFindZero = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 未找零禁止运行 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 禁止左行 报警提示;
    int readAddr6 = 42;

    QModbusDataUnit readUnit6(QModbusDataUnit::Coils,readAddr6,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit6,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ForbidLeftRun = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 禁止左行 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 禁止右行 报警提示;
    int readAddr7 = 43;

    QModbusDataUnit readUnit7(QModbusDataUnit::Coils,readAddr7,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit7,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ForbidRightRun = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 禁止右行 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 当前位置等于定位位置 报警提示;
    int readAddr8 = 47;

    QModbusDataUnit readUnit8(QModbusDataUnit::Coils,readAddr8,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit8,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            CurrentLocationEqualLocation = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 当前位置等于定位位置 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 未选择电机 报警提示;
    int readAddr9 = 64;

    QModbusDataUnit readUnit9(QModbusDataUnit::Coils,readAddr9,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit9,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            NotChooseMechine = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 未选择电机 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 工作中禁止压料 报警提示;
    int readAddr10 = 68;

    QModbusDataUnit readUnit10(QModbusDataUnit::Coils,readAddr10,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit10,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            WorkingForbidImpact = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 工作中禁止压料 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 锯片后位异常禁止压料 报警提示;
    int readAddr11 = 69;

    QModbusDataUnit readUnit11(QModbusDataUnit::Coils,readAddr11,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit11,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            SawErrForbidImpact = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 锯片后位异常禁止压料 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 锯片未启动禁止出锯 报警提示;
    int readAddr12 = 76;

    QModbusDataUnit readUnit12(QModbusDataUnit::Coils,readAddr12,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit12,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            SawNotRunForbidOut = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 锯片未启动禁止出锯 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 未压料禁止出锯 报警提示;
    int readAddr13 = 77;

    QModbusDataUnit readUnit13(QModbusDataUnit::Coils,readAddr13,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit13,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            NotImpactForbidOut = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 未压料禁止出锯 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 当前位置禁止出锯 报警提示;
    int readAddr14 = 80;

    QModbusDataUnit readUnit14(QModbusDataUnit::Coils,readAddr14,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit14,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            CurrentLocationForbidOut = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 当前位置禁止出锯 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 自动打印启动中继 报警提示;
    int readAddr15 = 135;

    QModbusDataUnit readUnit15(QModbusDataUnit::Coils,readAddr15,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit15,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            AutoPrintRun = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 自动打印启动中继 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 设定超短小于超短料长 报警提示;
    int readAddr16 = 134;

    QModbusDataUnit readUnit16(QModbusDataUnit::Coils,readAddr16,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit16,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            SetExtraShortLessCDLC = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 设定超短小于超短料长 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 锯片到位信号异常 报警提示;
    int readAddr17 = 137;

    QModbusDataUnit readUnit17(QModbusDataUnit::Coils,readAddr17,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit17,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            SawInPlaceSignalErr = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 锯片到位信号异常 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 位置清零完成 报警提示;
    int readAddr18 = 152;

    QModbusDataUnit readUnit18(QModbusDataUnit::Coils,readAddr18,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit18,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            LocationZeroOver = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 位置清零完成 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 禁止右机头移动 报警提示;
    int readAddr19 = 159;

    QModbusDataUnit readUnit19(QModbusDataUnit::Coils,readAddr19,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit19,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ForbidRightMechineMove = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 禁止右机头移动 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 超长定位 报警提示;
    int readAddr20 = 149;

    QModbusDataUnit readUnit20(QModbusDataUnit::Coils,readAddr20,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit20,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ExtraLongLocation = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 超长定位提示 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 切换锯方式提示 报警提示;
    int readAddr21 = 164;

    QModbusDataUnit readUnit21(QModbusDataUnit::Coils,readAddr21,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit21,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ChangeSawMethod = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 切换锯方式提示 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 误差修正完成 报警提示;
    int readAddr22 = 170;

    QModbusDataUnit readUnit22(QModbusDataUnit::Coils,readAddr22,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit22,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ErrCorrected = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 误差修正完成 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 禁止45度内摆 报警提示;
    int readAddr23 = 153;

    QModbusDataUnit readUnit23(QModbusDataUnit::Coils,readAddr23,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit23,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            Forbid_45NB = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 禁止45度内摆 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 超短复位 报警提示;
    int readAddr24 = 143;

    QModbusDataUnit readUnit24(QModbusDataUnit::Coils,readAddr24,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit24,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ExtraShortOrigin = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 超短复位 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 清除电池报警 报警提示;
    int readAddr25 = 196;

    QModbusDataUnit readUnit25(QModbusDataUnit::Coils,readAddr25,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit25,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            CleanBatteryWarning = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 清除电池报警 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 电池报警已清除 报警提示;
    int readAddr26 = 197;

    QModbusDataUnit readUnit26(QModbusDataUnit::Coils,readAddr26,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit26,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            CleanBatteryDone = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 电池报警已清除 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 前托信号异常 报警提示;
    int readAddr27 = 250;

    QModbusDataUnit readUnit27(QModbusDataUnit::Coils,readAddr27,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit27,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            Q_TL_Err = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 前托信号异常 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 中托信号异常 报警提示;
    int readAddr28 = 251;

    QModbusDataUnit readUnit28(QModbusDataUnit::Coils,readAddr28,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit28,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            Z_TL_Err = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 中托信号异常 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    // 读取 后托信号异常 报警提示;
    int readAddr29 = 252;

    QModbusDataUnit readUnit29(QModbusDataUnit::Coils,readAddr29,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit29,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            H_TL_Err = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 后托信号异常 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }

}

void ModBusControl::read_Mechine_Running_Message_state()
{
    int readAddr1 = 103;

    QModbusDataUnit readUnit1(QModbusDataUnit::Coils,readAddr1,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit1,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            ExtraLong_Locating = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 超长定位中 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }

    int readAddr2 = 96;

    QModbusDataUnit readUnit2(QModbusDataUnit::Coils,readAddr2,3);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit2,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            Long_WorkState = resultUnit.value(0);
                            Short_WorkState = resultUnit.value(1);
                            JM_WorkState = resultUnit.value(2);
                        }
                        else
                        {
                            qDebug()<<"读取 设备加工状态 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }

    int readAddr3 = 6;

    QModbusDataUnit readUnit3(QModbusDataUnit::Coils,readAddr3,4);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit3,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();
                            MechineRunningState = resultUnit.value(0);
                            qDebug()<<"M7 : "<<MechineRunningState;
                            FindZeroState = resultUnit.value(1);
                            qDebug()<<"M9 : "<<FindZeroState;
                            ZeroGoingState = resultUnit.value(3);
                            qDebug()<<"M6 : "<<ZeroGoingState;
                        }
                        else
                        {
                            qDebug()<<"读取 设备当前状态 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LG_value()
{
    // qDebug()<<"读取 - 料高设定值";
    int readAddr = 214;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            LG_value = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_CurrentLocation_value()
{
    // qDebug()<<"读取 当前位置";
    int readAddr = 196;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            CurrentLocation = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_XAxisCurrentLocation_value()
{
    // qDebug()<<"读取 X轴当前位置值";
    int readAddr = 204;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            XAxisCurrentLocation = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_CurrentSectiones_value()
{
    // qDebug()<<"读取 当前段数";

    int readAddr = 231;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            CurrentSectiones = (QString("%1").arg(QString::number(resultUnit.value(0),'f',2)));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LCSetting_value()
{
    // qDebug()<<"读取 料长设定值";

    int readAddr = 212;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            LC_value = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_SectionesSetting_value()
{
    // qDebug()<<"读取 段数设定值";

    int readAddr = 230;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            sectionSetting = (QString("%1").arg(QString::number(resultUnit.value(0),'f',2)));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LGObserve_value()
{
    // qDebug()<<"读取 料高测量值";

    int readAddr = 106;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            LGObserve = (QString("%1").arg(combinationToInt(resultUnit.value(1),resultUnit.value(0))));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LeftSawAngle_Backvalue()
{
    // qDebug()<<"读取 - 左锯角度反馈";
    int readAddr = 390;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            leftSawAngleBack = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_RightSawAngle_Backvalue()
{
    // qDebug()<<"读取 - 右锯角度反馈";
    int readAddr = 391;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            rightSawAngleBack = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_knobMode_value()
{
    // qDebug()<<"读取 - 旋钮模式";
    int readAddr = 229;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            knobMode = QString("%1").arg(resultUnit.value(0));
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LeftSawQW_state()
{
    // qDebug()<<"读取 - 左锯片前位";
    int readAddr = 13324;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            leftSawQW = resultUnit.value(0);
                            // qDebug()<<"左锯片前位: "<<leftSawQW;
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LeftSawHW_state()
{
    // qDebug()<<"读取 - 左锯片后位";
    int readAddr = 13322;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            leftSawHW = resultUnit.value(0);
                            // qDebug()<<"左锯片后位: "<<leftSawHW;
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_RightSawQW_state()
{
    // qDebug()<<"读取 - 右锯片前位";
    int readAddr = 13325;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            rightSawQW = resultUnit.value(0);
                            // qDebug()<<"右锯片前位: "<<rightSawQW;
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_RightSawHW_state()
{
    // qDebug()<<"读取 - 右锯片后位";
    int readAddr = 13323;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            rightSawHW = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LG_Observe_State_()
{
    // qDebug()<<"读取 - 压紧，锯片，工进";
    int readAddr = 109;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,3);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            lg_observe_state = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_ImpactState_state()
{
    // qDebug()<<"读取 - 压紧，锯片，工进";
    int readAddr = 239;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,3);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            impactState = resultUnit.value(0);

                            sawState = resultUnit.value(1);

                            gjState = resultUnit.value(2);

                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_BS_Location_value()
{
    // qDebug()<<"读取 - 把手位置";
    int readAddr = 282;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            LS_Locatoin = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_BS_LocationCompensate_value()
{
    // qDebug()<<"读取 - 把手位置补偿";
    int readAddr = 378;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            LS_LocationCompensate = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_BS_Width_value()
{
    // qDebug()<<"读取 - 把手位置补偿";
    int readAddr = 284;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            LS_Width = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_ExtraLong_LC_value()
{
    // qDebug()<<"读取 超长料长";

    int readAddr = 226;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            ExtraLong_LC = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_MechineLocation_value()
{
    // qDebug()<<"读取 机械坐标";

    int readAddr = 46;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            MechineLocation = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_ExtraLongCompensate_value()
{
    // qDebug()<<"读取 超长补偿";

    int readAddr = 172;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            ExtraLongCompensate = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_ExtraShort_LC_value()
{
    // qDebug()<<"读取 超短料长";

    int readAddr = 224;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            ExtraShort_LC = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_HL_Distance_value()
{
    // qDebug()<<"读取 回拉距离";

    int readAddr = 1390;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            HL_Distance = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_ExtraShortCompensate_value()
{
    // qDebug()<<"读取 超短补偿";

    int readAddr = 1380;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            ExtraShortCompensate = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Origin_value()
{
    // qDebug()<<"读取 原点值";

    int readAddr = 210;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            OriginValue = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_NB_SafeLocation_value()
{
    // qDebug()<<"读取 内摆安全位置";

    int readAddr = 1394;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            NB_SafeLocation = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_NB_WB_value()
{
    // qDebug()<<"读取 内摆外摆";
    int readAddr = 394;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            NBWB_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_JT_Knob_Mode_value()
{
    // qDebug()<<"读取 机头旋钮模式";
    int readAddr = 503;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            JT_Knob_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::reaed_DCF_Power_Mode_value()
{
    // qDebug()<<"读取 电磁阀断电模式";
    int readAddr = 509;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            DCF_Power_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Scram_Mode_value()
{
    // qDebug()<<"读取 急停按钮模式";
    int readAddr = 500;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Scram_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Encoder_Mode_value()
{
    // qDebug()<<"读取 编码器位数";
    int readAddr = 400;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Encoder_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Servo_Warning_Mode_value()
{
    // qDebug()<<"读取 伺服报警模式";
    int readAddr = 501;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Servo_Warning_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_DoubleSaw_Open_value()
{
    // qDebug()<<"读取 双锯延时开关";
    int readAddr = 399;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            DoubleSaw_Open = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_DoubleSaw_Delay_value()
{
    // qDebug()<<"读取 双锯延时时间";

    int readAddr = 1562;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            DoubleSaw_Delay = QString("%1").arg(resultUnit.value(0));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::readWarningSignal()
{
    int readAdd1 = 2;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAdd1,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            // qDebug()<<"读取限位位置操作成功";
                            const QModbusDataUnit resultUnit = reply->result();
                            scramWarnSig = resultUnit.value(0);
                            servoWarnSig = resultUnit.value(1);
                        }
                        else
                        {
                            qDebug()<<"读取操作失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }

    int readAdd2 = 31;

    QModbusDataUnit readUnit2(QModbusDataUnit::Coils,readAdd2,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit2,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            // qDebug()<<"读取限位位置操作成功";
                            const QModbusDataUnit resultUnit = reply->result();
                            F_LimitWarnSig = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取操作失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
    int readAdd3 = 36;

    QModbusDataUnit readUnit3(QModbusDataUnit::Coils,readAdd3,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnit3,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            // qDebug()<<"读取限位位置操作成功";
                            const QModbusDataUnit resultUnit = reply->result();
                            R_LimitWarnSig = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取操作失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }

}

void ModBusControl::read_Knob_Location_value()
{
    // qDebug()<<"读取 电机旋钮位置";
    int readAddr = 229;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Knob_Location = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Wokred_Count_PL_values()
{
    // qDebug()<<"读取 已切数量 - 排料加工";
    int readAddr = 1500;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,20);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            workedCount01_PL = QString("%1").arg(resultUnit.value(0));
                            workedCount02_PL = QString("%1").arg(resultUnit.value(1));
                            workedCount03_PL = QString("%1").arg(resultUnit.value(2));
                            workedCount04_PL = QString("%1").arg(resultUnit.value(3));
                            workedCount05_PL = QString("%1").arg(resultUnit.value(4));
                            workedCount06_PL = QString("%1").arg(resultUnit.value(5));
                            workedCount07_PL = QString("%1").arg(resultUnit.value(6));
                            workedCount08_PL = QString("%1").arg(resultUnit.value(7));
                            workedCount09_PL = QString("%1").arg(resultUnit.value(8));
                            workedCount10_PL = QString("%1").arg(resultUnit.value(9));
                            workedCount11_PL = QString("%1").arg(resultUnit.value(10));
                            workedCount12_PL = QString("%1").arg(resultUnit.value(11));
                            workedCount13_PL = QString("%1").arg(resultUnit.value(12));
                            workedCount14_PL = QString("%1").arg(resultUnit.value(13));
                            workedCount15_PL = QString("%1").arg(resultUnit.value(14));
                            workedCount16_PL = QString("%1").arg(resultUnit.value(15));
                            workedCount17_PL = QString("%1").arg(resultUnit.value(16));
                            workedCount18_PL = QString("%1").arg(resultUnit.value(17));
                            workedCount19_PL = QString("%1").arg(resultUnit.value(18));
                            workedCount20_PL = QString("%1").arg(resultUnit.value(19));

                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::reaed_M_Length_QR_values()
{
    // qDebug()<<"读取 二维码料单 切割长度";
    int readAddr = 1600;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,40);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            m_Length01_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                            m_Length02_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(3),resultUnit.value(2)),0,'f',2));
                            m_Length03_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(5),resultUnit.value(4)),0,'f',2));
                            m_Length04_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(7),resultUnit.value(6)),0,'f',2));
                            m_Length05_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(9),resultUnit.value(8)),0,'f',2));
                            m_Length06_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(11),resultUnit.value(10)),0,'f',2));
                            m_Length07_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(13),resultUnit.value(12)),0,'f',2));
                            m_Length08_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(15),resultUnit.value(14)),0,'f',2));
                            m_Length09_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(17),resultUnit.value(16)),0,'f',2));
                            m_Length10_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(19),resultUnit.value(18)),0,'f',2));
                            m_Length11_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(21),resultUnit.value(20)),0,'f',2));
                            m_Length12_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(23),resultUnit.value(22)),0,'f',2));
                            m_Length13_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(25),resultUnit.value(24)),0,'f',2));
                            m_Length14_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(27),resultUnit.value(26)),0,'f',2));
                            m_Length15_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(29),resultUnit.value(28)),0,'f',2));
                            m_Length16_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(31),resultUnit.value(30)),0,'f',2));
                            m_Length17_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(33),resultUnit.value(32)),0,'f',2));
                            m_Length18_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(35),resultUnit.value(34)),0,'f',2));
                            m_Length19_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(37),resultUnit.value(36)),0,'f',2));
                            m_Length20_QR = (QString("%1").arg(combinationToFloat(resultUnit.value(39),resultUnit.value(38)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Left_Right_Angle_QR_values()
{
    // qDebug()<<"读取 二维码料单 切割长度";
    int readAddr = 1640;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,40);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            LeftAngle01_QR = QString("%1").arg(resultUnit.value(0));
                            RightAngle01_QR = QString("%1").arg(resultUnit.value(1));

                            LeftAngle02_QR = QString("%1").arg(resultUnit.value(2));
                            RightAngle02_QR = QString("%1").arg(resultUnit.value(3));

                            LeftAngle03_QR = QString("%1").arg(resultUnit.value(4));
                            RightAngle03_QR = QString("%1").arg(resultUnit.value(5));

                            LeftAngle04_QR = QString("%1").arg(resultUnit.value(6));
                            RightAngle04_QR = QString("%1").arg(resultUnit.value(7));

                            LeftAngle05_QR = QString("%1").arg(resultUnit.value(8));
                            RightAngle05_QR = QString("%1").arg(resultUnit.value(9));

                            LeftAngle06_QR = QString("%1").arg(resultUnit.value(10));
                            RightAngle06_QR = QString("%1").arg(resultUnit.value(11));

                            LeftAngle07_QR = QString("%1").arg(resultUnit.value(12));
                            RightAngle07_QR = QString("%1").arg(resultUnit.value(13));

                            LeftAngle08_QR = QString("%1").arg(resultUnit.value(14));
                            RightAngle08_QR = QString("%1").arg(resultUnit.value(15));

                            LeftAngle09_QR = QString("%1").arg(resultUnit.value(16));
                            RightAngle09_QR = QString("%1").arg(resultUnit.value(17));

                            LeftAngle10_QR = QString("%1").arg(resultUnit.value(18));
                            RightAngle10_QR = QString("%1").arg(resultUnit.value(19));

                            LeftAngle11_QR = QString("%1").arg(resultUnit.value(20));
                            RightAngle11_QR = QString("%1").arg(resultUnit.value(21));

                            LeftAngle12_QR = QString("%1").arg(resultUnit.value(22));
                            RightAngle12_QR = QString("%1").arg(resultUnit.value(23));

                            LeftAngle13_QR = QString("%1").arg(resultUnit.value(24));
                            RightAngle13_QR = QString("%1").arg(resultUnit.value(25));

                            LeftAngle14_QR = QString("%1").arg(resultUnit.value(26));
                            RightAngle14_QR = QString("%1").arg(resultUnit.value(27));

                            LeftAngle15_QR = QString("%1").arg(resultUnit.value(28));
                            RightAngle15_QR = QString("%1").arg(resultUnit.value(29));

                            LeftAngle16_QR = QString("%1").arg(resultUnit.value(30));
                            RightAngle16_QR = QString("%1").arg(resultUnit.value(31));

                            LeftAngle17_QR = QString("%1").arg(resultUnit.value(32));
                            RightAngle17_QR = QString("%1").arg(resultUnit.value(33));

                            LeftAngle18_QR = QString("%1").arg(resultUnit.value(34));
                            RightAngle18_QR = QString("%1").arg(resultUnit.value(35));

                            LeftAngle19_QR = QString("%1").arg(resultUnit.value(36));
                            RightAngle19_QR = QString("%1").arg(resultUnit.value(37));

                            LeftAngle20_QR = QString("%1").arg(resultUnit.value(38));
                            RightAngle20_QR = QString("%1").arg(resultUnit.value(39));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}



void ModBusControl::read_Count_QR_values()
{
    // qDebug()<<"读取 二维码料单 切割数量";
    int readAddr = 1680;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,20);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Count01_QR = QString("%1").arg(resultUnit.value(0));
                            Count02_QR = QString("%1").arg(resultUnit.value(1));
                            Count03_QR = QString("%1").arg(resultUnit.value(2));
                            Count04_QR = QString("%1").arg(resultUnit.value(3));
                            Count05_QR = QString("%1").arg(resultUnit.value(4));
                            Count06_QR = QString("%1").arg(resultUnit.value(5));
                            Count07_QR = QString("%1").arg(resultUnit.value(6));
                            Count08_QR = QString("%1").arg(resultUnit.value(7));
                            Count09_QR = QString("%1").arg(resultUnit.value(8));
                            Count10_QR = QString("%1").arg(resultUnit.value(9));
                            Count11_QR = QString("%1").arg(resultUnit.value(10));
                            Count12_QR = QString("%1").arg(resultUnit.value(11));
                            Count13_QR = QString("%1").arg(resultUnit.value(12));
                            Count14_QR = QString("%1").arg(resultUnit.value(13));
                            Count15_QR = QString("%1").arg(resultUnit.value(14));
                            Count16_QR = QString("%1").arg(resultUnit.value(15));
                            Count17_QR = QString("%1").arg(resultUnit.value(16));
                            Count18_QR = QString("%1").arg(resultUnit.value(17));
                            Count19_QR = QString("%1").arg(resultUnit.value(18));
                            Count20_QR = QString("%1").arg(resultUnit.value(19));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Worked_Count_QR_values()
{
    // qDebug()<<"读取 二维码料单 已切数量";
    int readAddr = 1700;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,20);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Worked_Count01_QR = QString("%1").arg(resultUnit.value(0));
                            Worked_Count02_QR = QString("%1").arg(resultUnit.value(1));
                            Worked_Count03_QR = QString("%1").arg(resultUnit.value(2));
                            Worked_Count04_QR = QString("%1").arg(resultUnit.value(3));
                            Worked_Count05_QR = QString("%1").arg(resultUnit.value(4));
                            Worked_Count06_QR = QString("%1").arg(resultUnit.value(5));
                            Worked_Count07_QR = QString("%1").arg(resultUnit.value(6));
                            Worked_Count08_QR = QString("%1").arg(resultUnit.value(7));
                            Worked_Count09_QR = QString("%1").arg(resultUnit.value(8));
                            Worked_Count10_QR = QString("%1").arg(resultUnit.value(9));
                            Worked_Count11_QR = QString("%1").arg(resultUnit.value(10));
                            Worked_Count12_QR = QString("%1").arg(resultUnit.value(11));
                            Worked_Count13_QR = QString("%1").arg(resultUnit.value(12));
                            Worked_Count14_QR = QString("%1").arg(resultUnit.value(13));
                            Worked_Count15_QR = QString("%1").arg(resultUnit.value(14));
                            Worked_Count16_QR = QString("%1").arg(resultUnit.value(15));
                            Worked_Count17_QR = QString("%1").arg(resultUnit.value(16));
                            Worked_Count18_QR = QString("%1").arg(resultUnit.value(17));
                            Worked_Count19_QR = QString("%1").arg(resultUnit.value(18));
                            Worked_Count20_QR = QString("%1").arg(resultUnit.value(19));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_CurrentSectiones_JM_value()
{
    // qDebug()<<"读取 角码当前段数";
    int readAddr = 1270;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            currentSectiones_JM = QString("%1").arg(QString::number(resultUnit.value(0),'f',0));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_WorkedSections_JM_value()
{
    // qDebug()<<"读取 角码累计段数";
    int readAddr = 1271;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            workedSectiones_JM = QString("%1").arg(QString::number(resultUnit.value(0),'f',0));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_MinLongth_JM_value()
{
    // qDebug()<<"读取 角码最短料长";

    int readAddr = 1292;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            MiniLongth_JM = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_MaterialLongth_JM_value()
{
    // qDebug()<<"读取 角码原料长度";

    int readAddr = 1276;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            MaterialLongth_JM = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_JMLongth_JM_value()
{
    // qDebug()<<"读取 角码长度";

    int readAddr = 1272;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            JMLongth_JM = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_JMSectiones_JM_value()
{
    // qDebug()<<"读取 角码段数";

    int readAddr = 228;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            JMSectiones_JM = QString("%1").arg(QString::number(resultUnit.value(0)));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_DB_JM_value()
{
    // qDebug()<<"读取 刀补";

    int readAddr = 1274;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            DB_JM = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_JMLongthErr_JM_value()
{
    // qDebug()<<"读取 - 角码长度错误";
    int readAddr = 114;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            JMLongthErr_JM = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LGObserveState_value()
{
    // qDebug()<<"读取 料高测量状态";
    int readAddr = 109;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            LGObserveState = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LocationSpeed_value()
{
    // qDebug()<<"读取 定位速度";

    int readAddr = 206;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            LocationSpeed = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_ManualSpeed_value()
{
    // qDebug()<<"读取 手动速度";

    int readAddr = 1392;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            ManualSpeed = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_ImpactTime_value()
{
    // qDebug()<<"读取 压紧时间";

    int readAddr = 1280;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            ImpactTime = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LeftSaw_GJTime_value()
{
    // qDebug()<<"读取 左锯工进时间";

    int readAddr = 232;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            LeftSaw_GJTime = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_RightSaw_GJTime_value()
{
    // qDebug()<<"读取 右锯工进时间";

    int readAddr = 234;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            RightSaw_GJTime = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_DoubleSaws45_Compensate_value()
{
    // qDebug()<<"读取 双锯45度补偿";

    int readAddr = 1384;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            DoubleSaws45_Compensate = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_SingleSaw45_Compensate_value()
{
    // qDebug()<<"读取 单锯45度补偿";

    int readAddr = 396;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            SingleSaw45_Compensate = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_45Safe_Distance_value()
{
    // qDebug()<<"读取 45度安全距离";

    int readAddr = 1394;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            safeDistance = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LR_Blow_Time_value()
{
    // qDebug()<<"读取 左右吹气时间";

    int readAddr = 374;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            LR_Blow_Time = QString("%1").arg(resultUnit.value(0));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LG_Detection_Time_value()
{
    // qDebug()<<"读取 料高检测时间";

    int readAddr = 1288;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            LG_Detection_Time = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LG_CC_DL_value()
{
    // qDebug()<<"读取 料高磁尺当量";

    int readAddr = 1290;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            LG_CC_DL = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_DCF_OutageDelay_value()
{
    // qDebug()<<"读取 电磁阀断电延时";

    int readAddr = 238;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            DCF_OutageDelay = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_AutoPrint_state()
{
    // qDebug()<<"读取 自动打印状态";
    int readAddr = 511;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            AutoPrint = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_Y0_Y25()
{
    // qDebug()<<"读取 - 磁尺A相";
    int readAddr = 13056;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,22);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            Y0 = resultUnit.value(0);
                            Y1 = resultUnit.value(1);
                            Y2 = resultUnit.value(2);
                            Y3 = resultUnit.value(3);
                            Y4 = resultUnit.value(4);
                            Y5 = resultUnit.value(5);
                            Y6 = resultUnit.value(6);
                            Y7 = resultUnit.value(7);
                            Y10 = resultUnit.value(8);
                            Y11 = resultUnit.value(9);
                            Y12 = resultUnit.value(10);
                            Y13 = resultUnit.value(11);
                            Y14 = resultUnit.value(12);
                            Y15 = resultUnit.value(13);
                            Y16 = resultUnit.value(14);
                            Y17 = resultUnit.value(15);
                            Y20 = resultUnit.value(16);
                            Y21 = resultUnit.value(17);
                            Y22 = resultUnit.value(18);
                            Y23= resultUnit.value(19);
                            Y24 = resultUnit.value(20);
                            Y25 = resultUnit.value(21);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X0()
{
    // qDebug()<<"读取 - 磁尺A相";
    int readAddr = 13312;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X0 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X1()
{
    // qDebug()<<"读取 - 磁尺B相";
    int readAddr = 13313;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X1 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X2()
{
    // qDebug()<<"读取 - 左机头旋钮";
    int readAddr = 13314;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X2 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X3()
{
    // qDebug()<<"读取 - 右机头旋转";
    int readAddr = 13315;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X3 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X5()
{
    // qDebug()<<"读取 - 急停按钮";
    int readAddr = 13317;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X5 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X6()
{
    // qDebug()<<"读取 - 压紧按钮";
    int readAddr = 13318;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X6 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X7()
{
    // qDebug()<<"读取 - 工进按钮";
    int readAddr = 13319;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X7 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X10()
{
    // qDebug()<<"读取 - 锯片启动按钮";
    int readAddr = 13320;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X10 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X11()
{
    // qDebug()<<"读取 - 锯片停止按钮";
    int readAddr = 13321;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X11 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X16()
{
    // qDebug()<<"读取 - 伺服报警";
    int readAddr = 13326;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X16 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X17()
{
    // qDebug()<<"读取 - 伺服准备好";
    int readAddr = 13327;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X17 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X20()
{
    // qDebug()<<"读取 - X轴原点";
    int readAddr = 13328;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X20 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X21()
{
    // qDebug()<<"读取 - X轴正限位";
    int readAddr = 13329;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X21 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X22()
{
    // qDebug()<<"读取 - X轴负限位";
    int readAddr = 13330;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X22 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X23()
{
    // qDebug()<<"读取 - 前托退到位";
    int readAddr = 13331;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X23 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X24()
{
    // qDebug()<<"读取 - 中托退到位";
    int readAddr = 13332;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X24 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_IO_X25()
{
    // qDebug()<<"读取 - 后托退到位";
    int readAddr = 13333;

    QModbusDataUnit readUnitH(QModbusDataUnit::DiscreteInputs,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            X25 = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Per_Pulse_Count_value()
{
    // qDebug()<<"读取 每圈脉冲数";

    int readAddr = 200;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Per_Pulse_Count = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Per_Move_Distance_value()
{
    // qDebug()<<"读取 每转位移量";

    int readAddr = 202;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Per_Move_Distance = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Max_Cut_Longth_value()
{
    // qDebug()<<"读取 最大切割长度";

    int readAddr = 216;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Max_Cut_Longth = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_R_Limit_value()
{
    // qDebug()<<"读取 反向软限位";

    int readAddr = 218;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            R_Limit = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_F_Zero_HSpeed_value()
{
    // qDebug()<<"读取 找零点高速";

    int readAddr = 220;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            F_Zero_HSpeed = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_F_Zero_LSpeed_value()
{
    // qDebug()<<"读取 找零点低速";

    int readAddr = 222;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            F_Zero_LSpeed = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_F_L_Speed_Time_value()
{
    // qDebug()<<"读取 加减速时间";

    int readAddr = 208;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            F_L_Speed_Time = QString("%1").arg(resultUnit.value(0));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Brake_Open_Time_value()
{
    // qDebug()<<"读取 刹车打开时间";

    int readAddr = 1278;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Brake_Open_Time = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Brake_Close_Delay_value()
{
    // qDebug()<<"读取 刹车关闭延时";

    int readAddr = 602;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            Brake_Close_Delay = QString("%1").arg(resultUnit.value(0));
                            float test = Brake_Close_Delay.toFloat();
                            Brake_Close_Delay = QString::number(test/10,'f',2);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Encoder_Data_value()
{
    // qDebug()<<"读取 编码器数据";

    int readAddr = 2;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Encoder_Data = QString("%1").arg(QString::number(resultUnit.value(0)));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_TLJ_State_value()
{
    // qDebug()<<"读取 检测托料架";
    int readAddr = 499;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            TLJ_State = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_TLJ_Safe_Distance_value()
{
    // qDebug()<<"读取 托料架安全距离";

    int readAddr = 612;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            TLJ_Safe_Distance = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));                            
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Q_TLJ_Over_value()
{
    // qDebug()<<"读取 前托料架退到位";
    int readAddr = 243;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Q_TLJ_Over = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Z_TLJ_Over_value()
{
    // qDebug()<<"读取 检测托料架";
    int readAddr = 244;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Z_TLJ_Over = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_H_TLJ_Over_value()
{
    // qDebug()<<"读取 检测托料架";
    int readAddr = 245;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            H_TLJ_Over = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Q_TLJ_Location_value()
{
    // qDebug()<<"读取 前托料架位置";

    int readAddr = 1294;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Q_TLJ_Location = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Z_TLJ_Up_Limit_value()
{
    // qDebug()<<"读取 中托料架上限";

    int readAddr = 1296;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Z_TLJ_Up_Limit = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Z_TLJ_Down_Limit_value()
{
    // qDebug()<<"读取 中托料架下限";

    int readAddr = 296;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Z_TLJ_Down_Limit = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_H_TLJ_Location_value()
{
    // qDebug()<<"读取 后托料架位置";

    int readAddr = 1298;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,2);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            H_TLJ_Location = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Q_TLJ_Enable_value()
{
    // qDebug()<<"读取 前托料架使能";

    int readAddr = 387;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Q_TLJ_Enable = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Q_TLJ_LSState_value()
{
    // qDebug()<<"读取 前托料架0大于1小于";

    int readAddr = 384;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Q_TLJ_LS_State = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Z_TLJ_Enable_value()
{
    // qDebug()<<"读取 中托料架使能";

    int readAddr = 388;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Z_TLJ_Enable = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_H_TLJ_Enable_value()
{
    // qDebug()<<"读取 后托料架使能";

    int readAddr = 389;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            H_TLJ_Enable = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_H_TLJ_LS_State_value()
{
    // qDebug()<<"读取 后托料架0大于1小于";

    int readAddr = 386;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            H_TLJ_LS_State = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Location_Compensate_values()
{
    // qDebug()<<"读取 位置补偿 1 - 20";

    int readAddr = 1302;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,40);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Location_Compensate01 = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                            Location_Compensate02 = (QString("%1").arg(combinationToFloat(resultUnit.value(3),resultUnit.value(2)),0,'f',2));
                            Location_Compensate03 = (QString("%1").arg(combinationToFloat(resultUnit.value(5),resultUnit.value(4)),0,'f',2));
                            Location_Compensate04 = (QString("%1").arg(combinationToFloat(resultUnit.value(7),resultUnit.value(6)),0,'f',2));
                            Location_Compensate05 = (QString("%1").arg(combinationToFloat(resultUnit.value(9),resultUnit.value(8)),0,'f',2));
                            Location_Compensate06 = (QString("%1").arg(combinationToFloat(resultUnit.value(11),resultUnit.value(10)),0,'f',2));
                            Location_Compensate07 = (QString("%1").arg(combinationToFloat(resultUnit.value(13),resultUnit.value(12)),0,'f',2));
                            Location_Compensate08 = (QString("%1").arg(combinationToFloat(resultUnit.value(15),resultUnit.value(14)),0,'f',2));
                            Location_Compensate09 = (QString("%1").arg(combinationToFloat(resultUnit.value(17),resultUnit.value(16)),0,'f',2));
                            Location_Compensate10 = (QString("%1").arg(combinationToFloat(resultUnit.value(19),resultUnit.value(18)),0,'f',2));
                            Location_Compensate11 = (QString("%1").arg(combinationToFloat(resultUnit.value(21),resultUnit.value(20)),0,'f',2));
                            Location_Compensate12 = (QString("%1").arg(combinationToFloat(resultUnit.value(23),resultUnit.value(22)),0,'f',2));
                            Location_Compensate13 = (QString("%1").arg(combinationToFloat(resultUnit.value(25),resultUnit.value(24)),0,'f',2));
                            Location_Compensate14 = (QString("%1").arg(combinationToFloat(resultUnit.value(27),resultUnit.value(26)),0,'f',2));
                            Location_Compensate15 = (QString("%1").arg(combinationToFloat(resultUnit.value(29),resultUnit.value(28)),0,'f',2));
                            Location_Compensate16 = (QString("%1").arg(combinationToFloat(resultUnit.value(31),resultUnit.value(30)),0,'f',2));
                            Location_Compensate17 = (QString("%1").arg(combinationToFloat(resultUnit.value(33),resultUnit.value(32)),0,'f',2));
                            Location_Compensate18 = (QString("%1").arg(combinationToFloat(resultUnit.value(35),resultUnit.value(34)),0,'f',2));
                            Location_Compensate19 = (QString("%1").arg(combinationToFloat(resultUnit.value(37),resultUnit.value(36)),0,'f',2));
                            Location_Compensate20 = (QString("%1").arg(combinationToFloat(resultUnit.value(39),resultUnit.value(38)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_BJ_Location_Compensate_values()
{
    // qDebug()<<"读取 摆角专补，下限，上限，位置补偿";

    int readAddr = 1374;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,6);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Location_DownLimit_BJ = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                            Location_UpLimit_BJ = (QString("%1").arg(combinationToFloat(resultUnit.value(3),resultUnit.value(2)),0,'f',2));
                            Location_Compensate_BJ = (QString("%1").arg(combinationToFloat(resultUnit.value(5),resultUnit.value(4)),0,'f',2));
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_BJZB_Btn_value()
{
    // qDebug()<<"读取 摆角专补开关";
    int readAddr = 421;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            BJZB_Btn = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Location_Compensate_Any_values()
{
    // qDebug()<<"读取 任意位置，下限，上限，位置补偿";

    int readAddr = 1750;

    QModbusDataUnit readUnitH(QModbusDataUnit::HoldingRegisters,readAddr,120);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Location_DownLimit01_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(1),resultUnit.value(0)),0,'f',2));
                            Location_UpLimit01_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(3),resultUnit.value(2)),0,'f',2));
                            Location_Compensate01_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(5),resultUnit.value(4)),0,'f',2));

                            Location_DownLimit02_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(7),resultUnit.value(6)),0,'f',2));
                            Location_UpLimit02_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(9),resultUnit.value(8)),0,'f',2));
                            Location_Compensate02_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(11),resultUnit.value(10)),0,'f',2));

                            Location_DownLimit03_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(13),resultUnit.value(12)),0,'f',2));
                            Location_UpLimit03_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(15),resultUnit.value(14)),0,'f',2));
                            Location_Compensate03_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(17),resultUnit.value(16)),0,'f',2));

                            Location_DownLimit04_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(19),resultUnit.value(18)),0,'f',2));
                            Location_UpLimit04_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(21),resultUnit.value(20)),0,'f',2));
                            Location_Compensate04_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(23),resultUnit.value(22)),0,'f',2));

                            Location_DownLimit05_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(25),resultUnit.value(24)),0,'f',2));
                            Location_UpLimit05_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(27),resultUnit.value(26)),0,'f',2));
                            Location_Compensate05_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(29),resultUnit.value(28)),0,'f',2));

                            Location_DownLimit06_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(31),resultUnit.value(30)),0,'f',2));
                            Location_UpLimit06_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(33),resultUnit.value(32)),0,'f',2));
                            Location_Compensate06_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(35),resultUnit.value(34)),0,'f',2));

                            Location_DownLimit07_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(37),resultUnit.value(36)),0,'f',2));
                            Location_UpLimit07_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(39),resultUnit.value(38)),0,'f',2));
                            Location_Compensate07_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(41),resultUnit.value(40)),0,'f',2));

                            Location_DownLimit08_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(43),resultUnit.value(42)),0,'f',2));
                            Location_UpLimit08_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(45),resultUnit.value(44)),0,'f',2));
                            Location_Compensate08_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(47),resultUnit.value(46)),0,'f',2));

                            Location_DownLimit09_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(49),resultUnit.value(48)),0,'f',2));
                            Location_UpLimit09_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(51),resultUnit.value(50)),0,'f',2));
                            Location_Compensate09_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(53),resultUnit.value(52)),0,'f',2));

                            Location_DownLimit10_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(55),resultUnit.value(54)),0,'f',2));
                            Location_UpLimit10_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(57),resultUnit.value(56)),0,'f',2));
                            Location_Compensate10_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(59),resultUnit.value(58)),0,'f',2));

                            Location_DownLimit11_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(61),resultUnit.value(60)),0,'f',2));
                            Location_UpLimit11_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(63),resultUnit.value(62)),0,'f',2));
                            Location_Compensate11_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(65),resultUnit.value(64)),0,'f',2));

                            Location_DownLimit12_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(67),resultUnit.value(66)),0,'f',2));
                            Location_UpLimit12_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(69),resultUnit.value(68)),0,'f',2));
                            Location_Compensate12_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(71),resultUnit.value(70)),0,'f',2));

                            Location_DownLimit13_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(73),resultUnit.value(72)),0,'f',2));
                            Location_UpLimit13_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(75),resultUnit.value(74)),0,'f',2));
                            Location_Compensate13_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(77),resultUnit.value(76)),0,'f',2));

                            Location_DownLimit14_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(79),resultUnit.value(78)),0,'f',2));
                            Location_UpLimit14_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(81),resultUnit.value(80)),0,'f',2));
                            Location_Compensate14_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(83),resultUnit.value(82)),0,'f',2));

                            Location_DownLimit15_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(85),resultUnit.value(84)),0,'f',2));
                            Location_UpLimit15_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(87),resultUnit.value(86)),0,'f',2));
                            Location_Compensate15_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(89),resultUnit.value(88)),0,'f',2));

                            Location_DownLimit16_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(91),resultUnit.value(90)),0,'f',2));
                            Location_UpLimit16_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(93),resultUnit.value(92)),0,'f',2));
                            Location_Compensate16_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(95),resultUnit.value(94)),0,'f',2));

                            Location_DownLimit17_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(97),resultUnit.value(96)),0,'f',2));
                            Location_UpLimit17_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(99),resultUnit.value(98)),0,'f',2));
                            Location_Compensate17_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(101),resultUnit.value(100)),0,'f',2));

                            Location_DownLimit18_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(103),resultUnit.value(102)),0,'f',2));
                            Location_UpLimit18_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(105),resultUnit.value(104)),0,'f',2));
                            Location_Compensate18_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(107),resultUnit.value(106)),0,'f',2));

                            Location_DownLimit19_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(109),resultUnit.value(108)),0,'f',2));
                            Location_UpLimit19_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(111),resultUnit.value(110)),0,'f',2));
                            Location_Compensate19_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(113),resultUnit.value(112)),0,'f',2));

                            Location_DownLimit20_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(115),resultUnit.value(114)),0,'f',2));
                            Location_UpLimit20_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(117),resultUnit.value(116)),0,'f',2));
                            Location_Compensate20_Any = (QString("%1").arg(combinationToFloat(resultUnit.value(119),resultUnit.value(118)),0,'f',2));

                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Compensate_Btn_Any_values()
{
    // qDebug()<<"读取 补偿开关 任意位置";
    int readAddr = 401;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,20);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            CompensateBtn01_Any = resultUnit.value(0);
                            CompensateBtn02_Any = resultUnit.value(1);
                            CompensateBtn03_Any = resultUnit.value(2);
                            CompensateBtn04_Any = resultUnit.value(3);
                            CompensateBtn05_Any = resultUnit.value(4);
                            CompensateBtn06_Any = resultUnit.value(5);
                            CompensateBtn07_Any = resultUnit.value(6);
                            CompensateBtn08_Any = resultUnit.value(7);
                            CompensateBtn09_Any = resultUnit.value(8);
                            CompensateBtn10_Any = resultUnit.value(9);
                            CompensateBtn11_Any = resultUnit.value(10);
                            CompensateBtn12_Any = resultUnit.value(11);
                            CompensateBtn13_Any = resultUnit.value(12);
                            CompensateBtn14_Any = resultUnit.value(13);
                            CompensateBtn15_Any = resultUnit.value(14);
                            CompensateBtn16_Any = resultUnit.value(15);
                            CompensateBtn17_Any = resultUnit.value(16);
                            CompensateBtn18_Any = resultUnit.value(17);
                            CompensateBtn19_Any = resultUnit.value(18);
                            CompensateBtn20_Any = resultUnit.value(19);
                        }
                        else
                        {
                            qDebug()<<"读取 双字寄存器 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_GJTIME_Mode_State()
{
    // qDebug()<<"读取 工进时间是否分开";
    int readAddr = 528;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            GJTIME_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_LS_Exist_value()
{
    // qDebug()<<"读取 拉手功能是否存在（PLC没有）";
    int readAddr = 529;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            LS_Exist = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Angle45_Mode_value()
{
    // qDebug()<<"读取 45度专切（PLC没有）";
    int readAddr = 530;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Angle45_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Printer_Exist_value()
{
    // qDebug()<<"读取 打印机是否存在";
    int readAddr = 398;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Printer_Exist = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Servo_Mode_value()
{
    // qDebug()<<"读取 伺服类型";
    int readAddr = 392;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Servo_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_TLJ_Exist_value()
{
    // qDebug()<<"读取 托料架是否存在";
    int readAddr = 397;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            TLJ_Exist = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_SawChoose_Mode_State()
{
    // qDebug()<<"读取 锯片选择";
    int readAddr = 393;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            SawChoose_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Auto_Observe_Exist_value()
{
    // qDebug()<<"读取 自动测高是否存在";
    int readAddr = 396;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            AutoObserve_Exist = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Limit_Btn_value()
{
    // qDebug()<<"读取 限位开关";
    int readAddr = 502;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            LimitBtn_Mode = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::read_Knob_Program_value()
{
    // qDebug()<<"读取 旋钮功能";
    int readAddr = 510;

    QModbusDataUnit readUnitH(QModbusDataUnit::Coils,readAddr,1);

    if(auto* reply = (m_Modbus->sendReadRequest(readUnitH,1))){
        if(!reply->isFinished())
        {
            connect(reply,&QModbusReply::finished,this,[reply, this]()
                    {
                        if(reply->error() == QModbusDevice::NoError)
                        {
                            const QModbusDataUnit resultUnit = reply->result();

                            // qDebug()<<"读取 双字寄存器 成功";
                            Knob_Program = resultUnit.value(0);
                        }
                        else
                        {
                            qDebug()<<"读取 线圈 失败"<<reply->errorString();
                        }

                        reply->deleteLater();
                    });
        }
    }
}

void ModBusControl::setConnectParameter(QString serialport,
                                        QString baudrate,
                                        QString databit,
                                        QString paritybit,
                                        QString stopbit)
{
    QSerialPort::BaudRate set_BaudRate;
    QSerialPort::DataBits set_DataBit;
    QSerialPort::Parity   set_ParityBit;
    QSerialPort::StopBits set_StopBit;

    // 设置 - 波特率
    if("115200" == baudrate){
        set_BaudRate = QSerialPort::Baud115200;
    }else if("57600" == baudrate){
        set_BaudRate = QSerialPort::Baud57600;
    }else if("38400" == baudrate){
        set_BaudRate = QSerialPort::Baud38400;
    }else if("19200" == baudrate){
        set_BaudRate = QSerialPort::Baud19200;
    }else if("9600" == baudrate){
        set_BaudRate = QSerialPort::Baud9600;
    }else if("4800" == baudrate){
        set_BaudRate = QSerialPort::Baud4800;
    }else if("2400" == baudrate){
        set_BaudRate = QSerialPort::Baud2400;
    }else {
        set_BaudRate = QSerialPort::Baud1200;
    }

    // 设置 - 数据位
    if("8" == databit){
        set_DataBit = QSerialPort::Data8;
    }else if("7" == databit){
        set_DataBit = QSerialPort::Data7;
    }else if("6" == databit){
        set_DataBit = QSerialPort::Data6;
    }else {
        set_DataBit = QSerialPort::Data5;
    }

    // 设置 - 校验位
    if("None" == paritybit){
        set_ParityBit = QSerialPort::NoParity;
    }else if("Even" == paritybit){
        set_ParityBit = QSerialPort::EvenParity;
    }else if("Odd" == paritybit){
        set_ParityBit = QSerialPort::OddParity;
    }else if("Mark" == paritybit){
        set_ParityBit = QSerialPort::MarkParity;
    }else {
        set_ParityBit = QSerialPort::SpaceParity;
    }

    // 设置 - 停止位
    if("1" == stopbit){
        set_StopBit = QSerialPort::OneStop;
    }else if("1.5" == stopbit){
        set_StopBit = QSerialPort::OneAndHalfStop;
    }else{
        set_StopBit = QSerialPort::TwoStop;
    }

    m_Modbus->setConnectionParameter(QModbusRtuSerialMaster::SerialPortNameParameter,serialport.section(':',0,0));
    m_Modbus->setConnectionParameter(QModbusRtuSerialMaster::SerialBaudRateParameter,set_BaudRate);
    m_Modbus->setConnectionParameter(QModbusRtuSerialMaster::SerialDataBitsParameter,set_DataBit);
    m_Modbus->setConnectionParameter(QModbusRtuSerialMaster::SerialParityParameter,set_ParityBit);
    m_Modbus->setConnectionParameter(QModbusRtuSerialMaster::SerialStopBitsParameter,set_StopBit);

}

void ModBusControl::connectMethod()
{
    if(m_Modbus->connectDevice())
    {
        if(m_Modbus->state() == QModbusDevice::ConnectedState)
        {
            qDebug()<<"Cpp : Modbus 设备已连接";

        }
    }
    else
    {
        if(m_Modbus->state() == QModbusDevice::UnconnectedState)
        {
            qDebug()<<"Cpp : Modbus 设备未连接";
        }
    }
}
